using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Mvc.Rendering;

public static class EnumHelper
{
    public static IEnumerable<SelectListItem> GetSelectList<TEnum>()
        where TEnum : struct, Enum
    {
        return Enum.GetValues(typeof(TEnum)).Cast<TEnum>().Select(e =>
            new SelectListItem
            {
                Value = e.ToString(),
                Text = e.GetType().GetMember(e.ToString())[0]
                    .GetCustomAttribute<DisplayAttribute>()?.Name ?? e.ToString()
            });
    }
} 